﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Campeonato.Common.BLL;

namespace PESWeb.Pages.Ranking
{
    public partial class RankingGeral : BasePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                int campID = -1;
                if (!string.IsNullOrEmpty(Request.Params["id"]) &&
                    int.TryParse(Request.Params["id"], out campID))
                {
                    this.CampeonatoCarregado = CampeonatoBLL.BuscarCampeonato(campID);                    
                }

                LoadRanking();

                this.ChangeFacebookMetaInfo("htmlHeaderContentPlaceHolder", 
                    AppSettingsHelper.GetSiteAddress(),
                    this.CampeonatoCarregado.Nome, 
                    this.CampeonatoCarregado.ID.ToString());
            }

            DropDownList ddlstCampeonatos = Master.FindControl("ddlstCampeonatos") as DropDownList;
            ddlstCampeonatos.SelectedIndexChanged += new EventHandler(LoadRanking);
        }

        private void LoadRanking()
        {
            LoadRanking(this, null);
        }

        private void LoadRanking(object sender, EventArgs e)
        {
            this.rankingGV.LoadRanking(this.CampeonatoCarregado, null);
        }
    }
}